
<!--
BENCH RESULT HTML!
-->
<?php 
$tabNr = 0;
?>
<script type="text/javascript">
function DomBenchToggle() {
	m = document.getElementById("DomBenchMini");
	a = document.getElementById("DomBenchAlpha");
	r = document.getElementById("DomBenchResult");
	if( a.style.display == "none" ) {
		a.style.display = "";
		r.style.display = "";
		
		obs = document.getElementsByTagName("object");
		for( var i=0; i<obs.length; i++) {
			obs[i].style.display = "none";
		}

		//m.style.display = "none";
		DomBenchSetCookie("DomBenchShow", 1,1);
	} else {
		a.style.display = "none";
		r.style.display = "none";
		//m.style.display = "";
		obs = document.getElementsByTagName("object");
		for( var i=0; i<obs.length; i++) {
			obs[i].style.display = "";
		}
		
		DomBenchSetCookie("DomBenchShow", 0,1);
	}
}
function DomBenchTab( tab ) {
	if( tab == null )
		tab = 0;

	for( i=0; i<DomBench_nrOfTabs; i++) {
		document.getElementById("DomBenctTab_"+i).style.display = "none";
	}
	document.getElementById("DomBenctTab_"+tab).style.display = "";
	DomBenchSetCookie("DomBenchTab", tab,1);
}
function DomBenchGetCookie(c_name){
	if (document.cookie.length>0) {
		c_start=document.cookie.indexOf(c_name + "=");
		if (c_start!=-1) { 
    		c_start=c_start + c_name.length+1;
    		c_end=document.cookie.indexOf(";",c_start);
    		if (c_end==-1) {
				c_end=document.cookie.length;
			}
			return unescape(document.cookie.substring(c_start,c_end));
   		 } 
	}
	return null;
}
function DomBenchSetCookie(c_name,value,expiredays){
	var exdate=new Date()
	exdate.setDate(exdate.getDate()+expiredays)
	document.cookie=c_name+ "=" +escape(value)+
	((expiredays==null) ? "" : ";expires="+exdate)
}
</script>
<style type="text/css">
<!--
#DomBenchMini, #DomBenchAlpha, #DomBenchResult {margin:0px; padding:0px; display: block; font-family: Arial, Helvetica, sans-serif; font-size: 12px; color: #000000;}
#DomBenchAlpha, #DomBenchMini {filter:alpha(opacity=80);-moz-opacity:0.8;opacity:0.8; }
#DomBenchMini {cursor: pointer; position: absolute; top: 10px; right: 10px; padding: 2px; border: 1px dotted #000000; background-color:#FFFFFF; }
#DomBenchAlpha, #DomBenchResult {z-index: 10001; position: absolute; top: 0px; left: 0px; width: 100%; height: 100%;}
#DomBenchAlpha {background-color:#000000; position:absolute;}
#DomBenchArea {width: 1000px; min-height: 700px; background-color:#FFFFFF; border: 2px solid #000000; margin-top: 60px; padding: 0 10px 5px 10px; text-align:left;}
#DomBenchContent {overflow: auto; width: 100%; height: 650px;}

#DomBenchArea a {text-decoration: none; color: #000000; }
.DomBenchHeader {padding: 4px; border-bottom: 3px double #CCCCCC; padding-bottom: 8px; margin-bottom: 5px; }
.DomBench-closeButton {display: block; float: right; margin: 5px;}
.DomBench-button {display: block; float: left; margin: 0 0 2px 2px; border: 1px dotted #CCCCCC; background-color:#FFFFFF; padding: 3px;  }
.DomBench-button:hover { background-color:#E8EEDF;}
.DomBench-warning {color:#FF0000; font-weight:bold;}

#DomBenchArea table { background-color:#CCCCCC; width: 100% }
#DomBenchArea table thead th { background-color:#E8EEDF; font-weight:bold; font-size: 13px; color: #5C733C; text-align:left;}
#DomBenchArea table tfoot th { background-color:#E8EEDF; font-weight:bold; font-size: 13px; color: #5C733C; text-align:left;}
#DomBenchArea table tfoot td { background-color:#E8EEDF; font-size: 13px; color: #000000; text-align:left; font-weight:bold;}
#DomBenchArea table td { background-color:#FFFFFF; text-align: left;}
#DomBenchArea table th { background-color:#FFFFFF; width: 150px; text-align:right; font-weight:bold;  }
#DomBenchArea table {font-size: 12px}



h1.DomBench-h1 {font-size: 14px; font-weight:bold; display:inline; }
-->
</style>

<div id="DomBenchMini" onClick="DomBenchToggle()">Time: <?php echo $data['overall']['totalTime'] ?></div>

<div id="DomBenchAlpha" style="display:none"></div>
<div id="DomBenchResult" style="display:none">
<center>
<div id="DomBenchArea">
	<div class="DomBenchHeader">
	<a class="DomBench-button" style="float: right" href="javascript:DomBenchToggle();">Close</a>
	<a class="DomBench-button" href="javascript:DomBenchTab(<?php echo $tabNr++?>)">Overall</a>
	<?php foreach( (array)$data['traces'] as $name => $value ) { ?>
	<a class="DomBench-button" href="javascript:DomBenchTab(<?php echo $tabNr++?>)">Trace:<?php echo $name ?>(<?php echo count($value)?>)</a>
	<?php }?>
	<?php foreach( (array)$data['libs'] as $name => $lib ) { ?>
	<a class="DomBench-button" href="javascript:DomBenchTab(<?php echo $tabNr++?>)">Lib:<?php echo $name ?></a>
	<?php }?>
	<?php foreach( (array)$data['gaps'] as $name => $gap ) { ?>
	<a class="DomBench-button" href="javascript:DomBenchTab(<?php echo $tabNr++?>)">Gaps:<?php echo $name ?></a>
	<?php }?>
	<br style="clear:both">
	</div>
	
	<?php $tabNr = 0;?>

	<div id="DomBenchContent">
	<!--
	OVERALL
	-->
	<div id="DomBenctTab_<?php echo $tabNr++?>">
		<table cellspacing="1" cellpadding="2" border="0">
			
			<thead>
			<tr>
				<th colspan="3">Overall</th>
			</tr>
			</thead>
			<tbody>
			<tr>
				<th> Total script time</th>
				<td> <?php echo $data['overall']['totalTime'] ?></td>
				<td> <?php echo $data['overall']['percent'] ?>%</td>
			</tr>
			<tr>
				<th> Misc script time</th>
				<td> <?php echo $data['overall']['freeTime'] ?></td>
				<td> <?php echo $data['overall']['freePercent'] ?>%</td>
			</tr>
			<tr>
				<th> Memory usage</th>
				<td> <?php echo round(memory_get_usage()/1024,2).'KB' ?></td>
				<td> <?php echo round(memory_get_usage(true)/1024,2).'KB' ?></td>
			</tr>
			<tr>
				<th> Memory peak usage</th>
				<td> <?php echo round(memory_get_peak_usage()/1024,2).'KB' ?></td>
				<td> <?php echo round(memory_get_peak_usage(true)/1024,2).'KB' ?></td>
			</tr>
			<tr>
				<th> Memory limit</th>
				<td colspan="2"> <?php echo round(ini_get('memory_limit'),2).'MB' ?></td>
			</tr>
			
			</tbody>
			<?php foreach( $data['libs'] as $name => $lib ) { ?>
			<thead>
			<tr>
				<th colspan="3"><?php echo $name ?></th>
			</tr>
			</thead>
			<tbody>
			<tr>
				<th>Total time</th>
				<td> <?php echo $lib['totalTime'] ?></td>
				<td> <?php echo $lib['percentFromTotal'] ?>%</td>
			</tr>
			<?php foreach( (array)$lib['overallFields'] as $key => $value ) {?>
			<tr>
				<th><?php echo $value ?></th>
				<td><?php echo $lib[$key] ?></td>
				<td></td>
			</tr>
			<?php }?>
			</tbody>
			<?php }?>
			<thead>
			<tr>
				<th colspan="3">DomMonitor</th>
			</tr>
			</thead>
			<tr>
				<th> Log time</th>
				<td> <?php echo ($logTimeData['time'] >0 ? $logTimeData['time'] : 'Logging is off') ?></td>
				<td></td>
			</tr>
			<tr>
				<th> Monitor create time</th>
				<td> <?php echo $monitorCreateTime-$logTimeData['time'] ?></td>
				<td></td>
			</tr>
			<tfoot>
			<tr>
				<td colspan="3"></td>
			</tr>
			</tfoot>
		</table>
	</div>
	
	
	
	<!--
	TRACE
	-->
	<?php foreach( (array)$data['traces'] as $name => $trace ) { ?>
		<div id="DomBenctTab_<?php echo $tabNr++?>">
			<table cellspacing="1" cellpadding="2" border="0">
				<thead>
				<tr>
					<th colspan="2">Trace: <?php echo $name; ?></th>
				</tr>
				</thead>
				<tbody>
				<?php foreach( $trace as $mes ) { ?>
				<tr>
					<td><?php echo $mes['value'] ?></td>
					<td width="20"><acronym title="<?php echo $mes['info'] ?>" style="cursor:pointer">(i)</acronym></td>
				</tr>
				<?php }?>
				</tbody>
			</table>
		</div>
	<?php }?>
	
	
	
	
	<!--
	LIBS
	-->
	<?php foreach( (array)$data['libs'] as $name => $lib ) { ?>
		<div id="DomBenctTab_<?php echo $tabNr++?>">
			<table cellspacing="1" cellpadding="4" border="0">
				<thead>
				<tr>
					<th colspan="4">Lib: <?php echo $name ?></th>
				</tr>
				</thead>
				<tbody>
				<?php foreach( (array)$lib['data'] as $i => $li ) { ?>
				<tr>
					<td width="20"><?php echo $i+1 ?> </td>
					<td width="60"><?php echo $li['totalTime'] ?> </td>
					<td width="60"><?php echo $li['percent'] ?>%</td>
					<td>
						<?php if( $li['info'] ){?>
							<acronym title="<?php echo $li['info'] ?>"><?php echo $li['value'] ?></acronym>
						<?php } else {?>
							<?php echo $li['value'] ?>
						<?php }?>
					</td>
				</tr>
				<?php }?>
				</tbody>
				<tfoot>
				<tr>
					<td width="20">&nbsp;</td>
					<td width="60"><?php echo $lib['totalTime'] ?></td>
					<td width="60"><?php echo $lib['percent'] ?>%</td>
					<th>Total</th>
				</tr>
				</tfoot>
			</table>
			
		</div>
	<?php }?>
	
	
	<!--
	GAPS
	-->
	<?php foreach( (array)$data['gaps'] as $name => $gap ) { ?>
		<div id="DomBenctTab_<?php echo $tabNr++?>">
			<table cellspacing="1" cellpadding="2" border="0">
				<thead>
				<tr>
					<th colspan="4">Gaps: <?php echo $name ?></th>
				</tr>

				</thead>
				<tbody>
				<?php foreach( $gap as $dat ) { ?>
				<tr>
					<td valign="top" width="40"><?php echo $dat['totalTime'] ?></td>
					<td valign="top" width="40"><?php echo $dat['percent'] ?>%</td>
					<td valign="top" width="40"><strong><?php echo $dat['name'] ?></strong></td>
					<td>
						<table cellspacing="1" cellpadding="2" border="0" style="margin-top: 6px; margin-bottom: 3px; ">
						<?php 
						$rs = 0;
						foreach( $dat['libs'] as $libName => $libDat ) { if( $libDat['totalTime'] > 0 ) { $rs++?>
						<tr>
							<td valign="top" width="50"><?php echo $libName ?></td>
							<td valign="top" width="40"><?php echo $libDat['totalTime'] ?></td>
							<td valign="top" width="40"><?php echo $libDat['percent'] ?>%</td>
							<td width="*">
							<?php foreach($libDat['data'] as $libLibDat ) {?>
							<?php echo $libLibDat['value'] ?><br>
							<?php }?>
							</td>
						</tr>
						<?php }}?>
						<?php if( $rs > 0) {?>
						<tr>
							<td>Free</td>
							<td><?php echo $dat['freeTime'] ?></td>
							<td><?php echo $dat['freePercent'] ?>%</td>
							<td></td>
						</tr>
						<?php }?>
						</table>
					
					</td>
				</tr>
				<?php }?>
				</tbody>
				<tfoot>
				<tr>
					<td width="40"><?php echo $data['overall']['totalTime'] ?></td>
					<td width="40"><?php echo $data['overall']['percent'] ?>%</td>
					<td width="40">&nbsp;</td>
					<th>Total</th>
				</tr>
				</tfoot>
				
			</table>
		</div>
	<?php }?>
	
	</div>
</div>
</center>
</div>
<script type="text/javascript">
if( DomBenchGetCookie("DomBenchShow") == 1)
	DomBenchToggle()
DomBench_nrOfTabs = <?php echo $tabNr; ?>;
DomBenchTab( DomBenchGetCookie("DomBenchTab") );
</script>